#ifndef __CLASS_DEFINE_H__
#define __CLASS_DEFINE_H__

#include "Includes.h"



/*--------------- Linklist ----------------*/
typedef struct Node
{
	struct Node * higher;   /* LinkList pointer ,pointer to higher level object's linklist*/
	struct Node * next;    /* LinkList pointer ,pointer to same level object*/
	struct Node * lower;  /* LinkList pointer ,pointer to lower level object's linklist*/
	
}NODE_TYPE;


/* ----------------Object Oriented------------------------*/

/*--------------- Base Class ----------------*/
typedef struct
{
	NODE_TYPE NODE;
	unsigned short Id; //Object Id
}_O_OBJECT_T;



typedef struct
{
	bool 	(*Init)(void* dev);
	bool 	(*Open)(void* dev);
	bool  (*Close)(void* dev);
	int		(*Read)(void* dev,void* data,int len);
	int 	(*Write)(void* dev,void* data,int len);
	int   (*Config)(void* dev,void* data);
	
	bool  (*OneShot)(void* dev,void* data);  //Start once
	
}_FILE_OPS_T;   //Sets of Driver Operation Functions;



/*-----------------Device Base Class Define --------------------*/
typedef enum{
	
	ERROR_NONE = 0,
	
}GENE_ERROR_T;

typedef enum{
	
	WARN_NONE = 0,
	
}GENE_WARN_T;



typedef struct _device_t
{
	_O_OBJECT_T Obj;
	
//	_INTERFACE_T Itf;   //Interface Port
	
//	_DRIVER_T * Driver;  // pointer to Driver
	
//	_FILE_OPS_T * Ops; // Sets of Driver Functions;
	
	#define DEV_NAME_LEN 16
	char *NameDev; // device's name
	
//	unsigned char BusType;   //bus type
	
	bool Error;  //Fault Error.   True:false ,usually device must be stopped
	bool Warn;	//Warnning   True:false , usually device have no necessary to stop 
	GENE_ERROR_T 	ErrCode;  //generally Error code
	GENE_WARN_T 	WarnCode;  //generally Warnning Code
	
	bool (*Init)(void* data);   //Init device 
	bool (*Open)(void* data);   //Open device  
	bool (*Close)(void* data);   //Close device  
	bool (*Reset)(void* data);   //Reset device  
	
	int (*Det_Err)(void* data);  // detect Error for device  
	int (*Get_Err)(void* data);  // get Error for device   
	int (*Diag)(void* data, struct _device_t * dev);     // diagnose for device    
	
//	NODE_TYPE ServList;  //List Of servers ????  ????: _SERVER_T 
	
}_DEVICE_T;



#define GET_DEVICE(x) ((_DEVICE_T*)x)
#define GET_OBJECT(x) ((_O_OBJECT_T*)x)
#define GET_NODE(x) 	((NODE_TYPE*)x)


#endif







